/**
 * Header for fields common to most interfaces.
 *
 * @author Timothy Flynn (trflynn@wpi.edu)
 * @modified by JTM 2012/04/11
 *
 * @version April 11, 2012
 */
#ifndef _COMMON_H_
#define _COMMON_H_

// Server (Physical Layer) port
#define SERVER_PORT 	5432

// Application Layer
// @modified by JTM 2012/04/11
#define APPSERVER_PORT 9001
#define APPCLIENT_PORT 9002

// Frame/packet field lengths
#define HEADER_LEN 	1
#define END_LEN		1
#define SEQ_NUM_LEN	5
#define ACK_NUM_LEN	5
#define CRC_LEN		5
#define DATA_LEN	3
#define FOOTER_LEN 	1
#define PACKET_LEN	(END_LEN + SEQ_NUM_LEN + DATA_LEN)
#define FRAME_LEN	(HEADER_LEN + PACKET_LEN + ACK_NUM_LEN + CRC_LEN + FOOTER_LEN)

// Max sizes
#define MAX_FRAME_SZ 	128
#define MAX_PACKET_SZ 	256
#define MAX_SEQ_NUM 	32767

// Hex values for DLE ETX
#define DLE                     0x10
#define ETX                     0x03

#define MAX_DB_SIZE             100
#define MAX_LOGIN_SIZE          10
#define MAX_FIRST_NAME_SIZE     20
#define MAX_LAST_NAME_SIZE      25
#define MAX_LOCATION_SIZE       30
#define MAX_ID_SIZE             9

// ITOA with 0-filling
char *stoa(short, int);
char *ustoa(unsigned short, int);

// Functions to run DL and PL
void *runPhysicalLayer(void *);
void *runDataLinkLayer(void *);

#endif
